/**
 * @filename:ApiServiceImpl 2022-9-25
 * @project Wonder Java前后台分离框架  1.1.0
 * Copyright(c) 2022 Wonder Co. Ltd. 
 * All right reserved. 
 */
package com.wonder.admin.service.impl;

import com.wonder.admin.domain.SysApi;
import com.wonder.admin.mapper.SysApiDao;
import com.wonder.admin.request.SysApiRequest;
import com.wonder.admin.service.SysApiService;
import com.wonder.common.utils.StringUtils;
import com.wonder.common.utils.MessageUtils;
import com.wonder.common.common.AjaxMap;
import java.util.Map;
import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**   
 * @Description:TODO(API接口服务实现)
 *
 * @version: 1.1.0
 * @author: Wonder
 * 
 */
@Service
public class SysApiServiceImpl  extends ServiceImpl<SysApiDao, SysApi> implements SysApiService  {

    /**
     * 验证API接口信息
     * 
     * @param Api信息
     * @return 结果
     */
    @Override
    public String validate(SysApi api,String type){
    
    
       return "";
    }
    
    /**
	 * Description:API接口分页返回
	 * @request:检索条件
	 * @page：分页参数
	 * @return:分页记录
	 */
	@Override 
	public IPage<SysApi> selectList(SysApiRequest request, Page<SysApi> page){
	    QueryWrapper<SysApi> queryWrapper = new QueryWrapper<>();
	    
	    if (null != request.getId()) {
	       queryWrapper.eq("id", request.getId());
	      }
	    
	    if (null != request.getMenu_id()) {
		       queryWrapper.eq("menu_id", request.getMenu_id());
		      }     
             
    
	    if(StringUtils.hasText(request.getOrder()) && StringUtils.hasText(request.getSort())){
	        if(request.getOrder().equals("desc")) {
	        		queryWrapper.orderByDesc(request.getSort());
	        }else {
	        		queryWrapper.orderByAsc(request.getSort());
	        }
	    }else{
			queryWrapper.orderByDesc("id");	
		}    		
		Page<SysApi> selectPage = this.baseMapper.selectPage(page, queryWrapper);

		return selectPage;
      }
        
    
	
}